/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import model.Laminaat;
import exceptions.NoNameGivenException;
import gui.panels.LaminateLayerPanel;
import model.Layer;
import java.util.Iterator;
import java.util.TreeMap;
import javax.swing.JOptionPane;

/**
 *
 * @author Memet
 */
public class laminateBuilder extends javax.swing.JFrame {

    TreeMap<Integer, LaminateLayerPanel> layerPanels;
    boolean saved;
    public laminateBuilder() {
        initComponents();
        saved = true;
        layerPanels = new TreeMap<Integer, LaminateLayerPanel>();
        refreshForm();
        System.out.println("constructor");
    }

    public void loadLaminate(Laminaat l)
    {
        newLaminate();
        saved = true;
        txtName.setText(l.getName());
        //Matrix lam = l.getLam();
        /*
        for(int i = 0; i<l.getLam().getRowDimension(); i++)
        {
            LaminateLayerPanel pane = new LaminateLayerPanel((int)lam.get(i, 0), lam.get(i, 2), Global.data.getMateriaal((int)lam.get(i, 1)), lam.get(i, 3));
            jToolBar1.add(pane);
                //jToolBar1.repaint();

                //jScrollPane2.repaint();
                layers.put((int)lam.get(i, 0), pane);
                //this.repaint();

        }*/
        
        //Loop through all layers
        int i = 1;
        for(Layer layer : l.getLayers())
        {
            LaminateLayerPanel pane = new LaminateLayerPanel(layer.getLamel().getId(), layer.getAngle(), layer.getLamel(), layer.getThickness());
            double d = layer.getLamel().getId();
            jToolBar1.add(pane);
//            layerPanels.put(layer.getLamel().getId(), pane);
            layerPanels.put(i, pane);
            i++;
        }
        
        this.validate();
        refreshForm();
    }

   public void newLaminate()
    {
        saved = true;
        jToolBar1.removeAll();
        layerPanels.clear();
        this.repaint();
        this.validate();
        refreshForm();
    }

//    public Laminaat buildLaminate()
//    {
//        Laminaat l = new Laminaat();
//        Iterator<Integer> keys = layers.keySet().iterator();
//        while(keys.hasNext())
//        {
//            LaminateLayerPanel pane = layers.get(keys.next());
//            Materiaal m = pane.getMat();
//            l.addRowAfter(m.getId(), pane.getAngle(), pane.getThickness());
//            
//        }
//        l.setNaam(txtName.getText());
//        return l;
//    }
   
       public Laminaat buildLaminate()
    {
        System.out.println("buildLaminate()");
        Laminaat l = new Laminaat();
        Iterator<Integer> keys = layerPanels.keySet().iterator();
        while(keys.hasNext())
        {
            LaminateLayerPanel pane = layerPanels.get(keys.next());
            Layer lay = new Layer(pane.getMat(),pane.getAngle(),pane.getThickness());
            l.addLayer(lay);
        }
        l.setName(txtName.getText());
        return l;
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar2 = new javax.swing.JToolBar();
        btnAddLayer = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        btnSymetric = new javax.swing.JButton();
        btnSelectAll = new javax.swing.JButton();
        btnDeselectAll = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        btnDuplicate = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        btnMoveUp = new javax.swing.JButton();
        btnMoveDown = new javax.swing.JButton();
        jSeparator4 = new javax.swing.JToolBar.Separator();
        btnDelete = new javax.swing.JButton();
        txtName = new javax.swing.JTextField();
        btnSavebtn = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jToolBar1 = new javax.swing.JToolBar();
        jMenuBar1 = new javax.swing.JMenuBar();
        mbtnFile = new javax.swing.JMenu();
        mbtnSave = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jToolBar2.setFloatable(false);

        btnAddLayer.setText("Add Layer");
        btnAddLayer.setFocusable(false);
        btnAddLayer.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnAddLayer.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnAddLayer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddLayerActionPerformed(evt);
            }
        });
        jToolBar2.add(btnAddLayer);
        jToolBar2.add(jSeparator1);

        btnSymetric.setText("Make symetric");
        btnSymetric.setFocusable(false);
        btnSymetric.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnSymetric.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnSymetric.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSymetricActionPerformed(evt);
            }
        });
        jToolBar2.add(btnSymetric);

        btnSelectAll.setText("Select all layers");
        btnSelectAll.setFocusable(false);
        btnSelectAll.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnSelectAll.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnSelectAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSelectAllActionPerformed(evt);
            }
        });
        jToolBar2.add(btnSelectAll);

        btnDeselectAll.setText("Deselect all layers");
        btnDeselectAll.setFocusable(false);
        btnDeselectAll.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnDeselectAll.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnDeselectAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeselectAllActionPerformed(evt);
            }
        });
        jToolBar2.add(btnDeselectAll);
        jToolBar2.add(jSeparator2);

        btnDuplicate.setText("Duplicate selected");
        btnDuplicate.setFocusable(false);
        btnDuplicate.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnDuplicate.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnDuplicate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDuplicateActionPerformed(evt);
            }
        });
        jToolBar2.add(btnDuplicate);
        jToolBar2.add(jSeparator3);

        btnMoveUp.setText("Move up");
        btnMoveUp.setFocusable(false);
        btnMoveUp.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnMoveUp.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnMoveUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMoveUpActionPerformed(evt);
            }
        });
        jToolBar2.add(btnMoveUp);

        btnMoveDown.setText("Move down");
        btnMoveDown.setFocusable(false);
        btnMoveDown.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnMoveDown.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnMoveDown.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMoveDownActionPerformed(evt);
            }
        });
        jToolBar2.add(btnMoveDown);
        jToolBar2.add(jSeparator4);

        btnDelete.setText("Delete selected");
        btnDelete.setFocusable(false);
        btnDelete.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnDelete.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteActionPerformed(evt);
            }
        });
        jToolBar2.add(btnDelete);

        txtName.setFont(new java.awt.Font("Trebuchet MS", 1, 24)); // NOI18N
        txtName.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtName.setText("<Name>");

        btnSavebtn.setText("Save Laminate");
        btnSavebtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSavebtnActionPerformed(evt);
            }
        });

        jToolBar1.setFloatable(false);
        jToolBar1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jScrollPane1.setViewportView(jToolBar1);

        mbtnFile.setText("File");


        mbtnSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        mbtnSave.setText("Save Laminate");
        mbtnSave.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                mbtnSaveMouseClicked(evt);
            }
        });
        mbtnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mbtnSaveActionPerformed(evt);
            }
        });
        mbtnSave.addMenuKeyListener(new javax.swing.event.MenuKeyListener() {
            public void menuKeyTyped(javax.swing.event.MenuKeyEvent evt) {
            }
            public void menuKeyPressed(javax.swing.event.MenuKeyEvent evt) {
                mbtnSaveMenuKeyPressed(evt);
            }
            public void menuKeyReleased(javax.swing.event.MenuKeyEvent evt) {
            }
        });
        mbtnFile.add(mbtnSave);

        jMenuBar1.add(mbtnFile);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(txtName, javax.swing.GroupLayout.DEFAULT_SIZE, 837, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jToolBar2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 817, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 666, Short.MAX_VALUE)
                        .addComponent(btnSavebtn, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 817, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 505, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnSavebtn, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void mbtnSaveMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mbtnSaveMouseClicked
        saveLaminate();
    }//GEN-LAST:event_mbtnSaveMouseClicked

    private void mbtnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mbtnSaveActionPerformed
        saveLaminate();
    }//GEN-LAST:event_mbtnSaveActionPerformed

    private void mbtnSaveMenuKeyPressed(javax.swing.event.MenuKeyEvent evt) {//GEN-FIRST:event_mbtnSaveMenuKeyPressed
        saveLaminate();
    }//GEN-LAST:event_mbtnSaveMenuKeyPressed

    private void btnAddLayerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddLayerActionPerformed
        saved = false;
        System.out.println("btnAddLayer()");
        LaminateLayerPanel l = new LaminateLayerPanel();
        int id;
        if (layerPanels.isEmpty()) {
            id = 1;
        } else {
            id = layerPanels.lastKey() + 1;
        }

        l.setNumber(id);
        jToolBar1.add(l);
        //jToolBar1.repaint();

        //jScrollPane2.repaint();
        layerPanels.put(id, l);
        //this.repaint();
        this.validate();
        refreshForm();
    }//GEN-LAST:event_btnAddLayerActionPerformed

    private void btnSymetricActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSymetricActionPerformed
        saved = false;
        System.out.println("btnSymetric");
        int end = layerPanels.lastKey();
        for (int i = end; i > 0; i--) {

            int id;
            if (layerPanels.isEmpty()) {
                id = 1;
            } else {
                id = layerPanels.lastKey() + 1;
            }
            LaminateLayerPanel l = new LaminateLayerPanel(id, layerPanels.get(i).getAngle(), layerPanels.get(i).getMat(), layerPanels.get(i).getThickness());



            jToolBar1.add(l);
            //jToolBar1.repaint();

            //jScrollPane2.repaint();
            layerPanels.put(id, l);
            //this.repaint();
            this.validate();
            refreshForm();
        }
    }//GEN-LAST:event_btnSymetricActionPerformed

    private void btnSelectAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelectAllActionPerformed
        for (int i = 1; i <= layerPanels.lastKey(); i++) {
            layerPanels.get(i).setSelected(true);
        }
    }//GEN-LAST:event_btnSelectAllActionPerformed

    private void btnDeselectAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeselectAllActionPerformed
        for (int i = 1; i <= layerPanels.lastKey(); i++) {
            layerPanels.get(i).setSelected(false);
        }
    }//GEN-LAST:event_btnDeselectAllActionPerformed

    private void btnDuplicateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDuplicateActionPerformed
        saved = false;

        int end = layerPanels.lastKey();
        for (int i = 1; i <= end; i++) {
            if (layerPanels.get(i).isSelected()) {
                int id;
                if (layerPanels.isEmpty()) {
                    id = 1;
                } else {
                    id = layerPanels.lastKey() + 1;
                }
                LaminateLayerPanel l = new LaminateLayerPanel(id, layerPanels.get(i).getAngle(), layerPanels.get(i).getMat(), layerPanels.get(i).getThickness());



                jToolBar1.add(l);
                //jToolBar1.repaint();

                //jScrollPane2.repaint();
                layerPanels.put(id, l);
                //this.repaint();
                this.validate();
            }
        }
        refreshForm();
    }//GEN-LAST:event_btnDuplicateActionPerformed

    private void btnMoveUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMoveUpActionPerformed
        saved = false;
        System.out.println("btnMoveUp");
        Laminaat l = buildLaminate();
//        int end = layerPanels.lastKey();
//        boolean[] checkers = new boolean[end + 2];
//        for (int j = 0; j < end + 2; j++) {
//            checkers[j] = false;
//        }
//        for (int i = 1; i <= end; i++) {
//            if (layerPanels.get(i).isSelected()) {
//                l.moveUp(i);
//                checkers[i - 1] = true;
//            }
//        }
//        int i = 2;
        boolean[] checked = new boolean[layerPanels.size()];
        for (int j = 0; j < checked.length; j++) {
            checked[j] = false;
        }
        System.out.println("layerpanels size: "+layerPanels.size());
        for (int i = 1; i < layerPanels.size(); i++) {
            System.out.println("i = "+i);
            if (layerPanels.get(i+1).isSelected()) {
                Layer lay1 = l.getLayers().get(i);
                l.updateLayer(i, l.getLayers().get(i-1));
                l.updateLayer(i-1, lay1);
                checked[i] = true;
            }
        }
//        for (Layer lay : l.layers) {
//            if (layerPanels.get(i).isSelected()) {
//                
//                l.layers.set(i, lay)
//            }
//            i++;
//        }
        loadLaminate(l);
        saved = false;

//        if (checkers[0]) {
//            checkers[1] = true;
//        }
//        if (checkers[end + 1]) {
//            checkers[end] = true;
//        }
        System.out.println("layerpanels size 2 = "+layerPanels.size());
        for (int i = 0; i < checked.length; i++) {
            if (checked[i]) {
                System.out.println("i checked = "+i);
                layerPanels.get(i).setSelected(true);
            }
        }
        refreshForm();
    }//GEN-LAST:event_btnMoveUpActionPerformed

    private void btnMoveDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMoveDownActionPerformed
        System.out.println("btnMoveDown");
        //moveDown();
        saved = false;
        Laminaat l = buildLaminate();
        
        boolean[] checked = new boolean[layerPanels.size()];
        for (int j = 0; j < checked.length; j++) {
            checked[j] = false;
        }
        System.out.println("layerpanels size: "+layerPanels.size());
        for (int i = 0; i < layerPanels.size()-1; i++) {
            System.out.println("i = "+i);
            if (layerPanels.get(i+1).isSelected()) {
                Layer lay1 = l.getLayers().get(i);
                l.updateLayer(i, l.getLayers().get(i+1));
                l.updateLayer(i+1, lay1);
                checked[i] = true;
            }
        }
        
        loadLaminate(l);
        saved = false;

        System.out.println("layerpanels size 2 = "+layerPanels.size());
        for (int i = 0; i < checked.length; i++) {
            if (checked[i]) {
                System.out.println("i checked = "+i);
                layerPanels.get(i+2).setSelected(true);
            }
        }
        refreshForm();
    }//GEN-LAST:event_btnMoveDownActionPerformed

    private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteActionPerformed
        saved = false;

        int end = layerPanels.lastKey();
        TreeMap<Integer, LaminateLayerPanel> layersTijdelijk = new TreeMap<Integer, LaminateLayerPanel>();
        int j = 1;
        for (int i = 1; i <= end; i++) {
            if (!layerPanels.get(i).isSelected()) {
                layerPanels.get(i).setNumber(j);
                layersTijdelijk.put(j, layerPanels.get(i));
            }
            j++;
        }
        layerPanels = layersTijdelijk;
        loadLaminate(buildLaminate());
        saved = false;
        refreshForm();
    }//GEN-LAST:event_btnDeleteActionPerformed

    private void btnSavebtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSavebtnActionPerformed
        saveLaminate();
    }//GEN-LAST:event_btnSavebtnActionPerformed

    public boolean closeActions()
    {

        if(!saved)
        {
            int msg = JOptionPane.showConfirmDialog(this,"Save the laminate?");
            if(msg == JOptionPane.YES_OPTION)
            {
                saveLaminate();
            }
            else if(msg == JOptionPane.CANCEL_OPTION || msg == JOptionPane.CLOSED_OPTION)
            {
                return false;
            }

        }
        
        this.dispose();
        return true;
    }
    
    private void moveDown(){
            saved = false;


        Laminaat l = buildLaminate();
       int end = layerPanels.lastKey();
       boolean[] checkers = new boolean[end+2];
       for(int j = 0; j<end+2; j++)
       {
           checkers[j]=false;
       }
        for(int i = end; i>0; i--)
        {

            if(layerPanels.get(i).isSelected())
            {
                //l.moveDown(i);
                if(!checkers[i+1])
                {
                    checkers[i+1]=true;
                }
                else
                {
                    checkers[i] = true;
                }
            }
        }
       loadLaminate(l);
       saved = false;
       
       if(checkers[0])
       {
           checkers[1] = true;
       }
       if(checkers[end+1])
       {
           checkers[end] = true;
       }
       for(int x = 1; x<=end; x++)
       {
           if(checkers[x])
           {
               layerPanels.get(x).setSelected(true);
           }
       }
}

    private void saveLaminate() {
//        Laminaat l = new Laminaat();
//
//        Iterator<Integer> keys = layers.keySet().iterator();
//        while(keys.hasNext())
//        {
//            LaminateLayerPane pane = layers.get(keys.next());
//            Materiaal m = pane.getMat();
//            l.addRowAfter(m.getId(), pane.getAngle(), pane.getThickness());
//            l.setNaam(txtName.getText());
//        }
        Laminaat l = buildLaminate();
            try {
                
                if(l.getName().equalsIgnoreCase(""))
                {
                    throw new NoNameGivenException();
                }/* todo refactor
                Global.data.setLaminaat(l, txtName.getText());
            } catch (NameAlreadyExistsException ex) {
                JOptionPane.showMessageDialog(rootPane, "The name you entered already exists");
            } catch (InvalidNameException ex) {
                JOptionPane.showMessageDialog(rootPane, "The name you entered is invalid");*/
            } catch (NoNameGivenException ex) {
                JOptionPane.showMessageDialog(rootPane, "Please enter a name for the laminate");
            }
        
        saved = true;

        this.loadLaminate(l);
        /* todo refactor
        Global.menu.refreshScreens();
        try
        {
            LaminateOperationPanel operations = (LaminateOperationPanel) Global.menu.operations;
            operations.setLaminate(l);
        }
        catch(Exception ex)
        {
            Global.menu.setOperations(new LaminateOperationPanel());
            LaminateOperationPanel operations = (LaminateOperationPanel) Global.menu.operations;
            operations.setLaminate(l);
        }
        finally{
            Global.menu.refreshScreens();
        }*/
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAddLayer;
    private javax.swing.JButton btnDelete;
    private javax.swing.JButton btnDeselectAll;
    private javax.swing.JButton btnDuplicate;
    private javax.swing.JButton btnMoveDown;
    private javax.swing.JButton btnMoveUp;
    private javax.swing.JButton btnSavebtn;
    private javax.swing.JButton btnSelectAll;
    private javax.swing.JButton btnSymetric;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JToolBar.Separator jSeparator4;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JToolBar jToolBar2;
    private javax.swing.JMenu mbtnFile;
    private javax.swing.JMenuItem mbtnSave;
    private javax.swing.JTextField txtName;
    // End of variables declaration//GEN-END:variables
    private void refreshForm() {/* todo refactor
        if(Global.data.materialenEmpty())
        {
            btnAddLayer.setEnabled(false);
        }
        else
        {
            btnAddLayer.setEnabled(true);
        }
        if(layerPanels.isEmpty())
        {
            btnDelete.setEnabled(false);
            btnDeselectAll.setEnabled(false);
            btnDuplicate.setEnabled(false);
            btnMoveDown.setEnabled(false);
            btnMoveUp.setEnabled(false);
            btnSelectAll.setEnabled(false);
            btnSymetric.setEnabled(false);
        }
        else
        {
            btnDelete.setEnabled(true);
            btnDeselectAll.setEnabled(true);
            btnDuplicate.setEnabled(true);
            btnMoveDown.setEnabled(true);
            btnMoveUp.setEnabled(true);
            btnSelectAll.setEnabled(true);
            btnSymetric.setEnabled(true);
        } */
    }
}


